package com.itheima.cs.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itheima.cs.R;
import com.itheima.cs.entity.ScanInStorage;

import java.util.List;

public class LvScanInStorageAdapter extends BaseAdapter {
    private Context context;
    private List<ScanInStorage> scanInStorageList;

    public LvScanInStorageAdapter() {
    }

    public LvScanInStorageAdapter(Context context, List<ScanInStorage> scanInStorageList) {
        this.context = context;
        this.scanInStorageList = scanInStorageList;
    }

    public void setScanInStorageList(List<ScanInStorage> scanInStorageList) {
        this.scanInStorageList = scanInStorageList;
    }

    @Override
    public int getCount() {
        return scanInStorageList.size();
    }

    @Override
    public Object getItem(int position) {
        return scanInStorageList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.production_orders_list_item,null);
            viewHolder = new ViewHolder();

            viewHolder.tv_document_number=convertView.findViewById(R.id.tv_document_number);
            viewHolder.tv_goods_number=convertView.findViewById(R.id.tv_goods_number);


            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder)convertView.getTag();
        }


        ScanInStorage item = scanInStorageList.get(position);
        viewHolder.tv_document_number.setText(item.getDocumentNumber());

        viewHolder.tv_goods_number.setText(item.getGoodsNumber());


        return convertView;
    }


    private class ViewHolder{
        private TextView tv_document_number,tv_document_state,tv_goods_number,tv_goods_name,tv_specifications_model;

    }
}
